<?php

/**
 * Tabela do texto inicial.
 *
 * @author Fernando Dias Oliveira <rodox17@gmail.com>
 * @package lore
 * @subpackage model
 */

class caf05 extends Zend_Db_Table_Abstract  
{
	protected $_table   = "caf05";
	protected $_primary = "caf05_cod";
	
	public function getProductByMenu($cod_menu, $cod)
	{
		$db = $this->getAdapter();
		$arr = array();
		
		//$arrTable = $db->fetchAll("SELECT distinct caf04.caf04_cod_prod, caf05_prod, caf05_car, caf03_menu, caf05_cod, caf05_valor FROM caf05, caf03, caf04 WHERE caf04_cod_prod = caf05_cod AND caf05_cod_menu = caf03_cod AND caf05_cod_menu = $cod_menu ORDER BY caf05_prod ASC");
		$arrTable = $db->fetchAll("SELECT * FROM caf05
									left join caf03 on(caf03_cod = caf05_cod_menu)
									left join caf04 on(caf05_cod = caf04_cod_prod AND caf04_cod_item = $cod)
									 WHERE caf05_cod_menu = caf03_cod AND 
									 caf05_cod_menu = $cod_menu
									 ORDER BY caf05_prod, caf05_car ASC");
		
		return $arrTable;
	}
	
	public function save($arrPost)
	{
		$this->insert($arrPost);
	}
}

?>
